#include <bits/stdc++.h>
#define gc getchar
#define pc putchar
#define pt printf
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rof(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
const int Mxn=1e6+5;
int N,Tp,Sk[Mxn],Fa[Mxn],Fg[Mxn];
int Ct,Nt[Mxn<<1],To[Mxn<<1],Hd[Mxn];
int _() {
	int x=0,f=0;char ch=gc();
	while(ch<'0'||ch>'9') f|=(ch=='-'),ch=gc();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=gc();
	return f?-x:x;
}
void __(int x) {
	int stk[30],tp=0;
	if(x<0) x=-x,pc('-');
	do stk[++tp]=x%10,x/=10;while(x);
	while(tp) pc(stk[tp--]^48);
}
void Merge(int x,int y) {
	Nt[++Ct]=Hd[x],To[Ct]=y,Hd[x]=Ct;
	Nt[++Ct]=Hd[y],To[Ct]=x,Hd[y]=Ct;
}
void DFS(int x) {
	for(int v,i=Hd[x];i;i=Nt[i]) {
		if((v=To[i])!=Fa[x]) {
			Fa[v]=x,Fg[v]=1,DFS(v);
		}
	}
}
signed main() {
	freopen("choice.in","r",stdin);
	freopen("choice.out","w",stdout);
	N=_();
	For(i,2,N) Merge(_(),_());
	Fg[1]=1,DFS(1);
	For(i,1,N) Fg[i]=0;
	For(i,1,N) {
		int x=i;
		while(x&&!Fg[x]) Fg[x]=1,Sk[++Tp]=x,x=Fa[x];
		while(Tp) __(Sk[Tp--]),pc(' ');
	}
	return 0;
}
